
function _BibleSearch(){
    var book=jQuery("#wbible_book").val();
       var chapter=jQuery("#wbible_chapter").val();
       var search=jQuery("#wbible_text").val();
       
       var sample="Nhập từ cần tìm...";
       
       if (search.toLowerCase() == sample.toLowerCase())
       {
           return;
       }
       
       search=encodeURI(search);
       
       var url="/search/"+search;
       if (book>-1)
       {
           url+="/book/"+book;
       }
       if (chapter>-1){
           url+="/chapter/"+chapter;
       }
       
       window.location=url;
}

jQuery(document).ready(function(){
    jQuery("#wbible_navigation").treeview({
        persist: "location",
        collapsed: true,
        unique: false
    }).show();
    
    
    jQuery("#wbible_text").focus(function(){
        jQuery(this).removeClass("wbible_search_outfocus").addClass("wbible_search_onfocus");
        if (jQuery(this).val() == "Nhập từ cần tìm...")
        {
            jQuery(this).val("");
        }
    });
    
    jQuery("#wbible_text").blur(function(){
        jQuery(this).removeClass("wbible_search_onfocus").addClass("wbible_search_outfocus");
        if (jQuery(this).val()=="")
        {
            jQuery(this).val("Nhập từ cần tìm...");
        }
    });
    
    // change event of the book selector
    /*jQuery("#wbible_book").change(function(){
         var chapters=wbible_data[jQuery(this).val()];
         var new_html="<option value='-1' disabled>Đoạn</option>";
         for (var i=1;i<=chapters;i++)
         {
             new_html+="<option value='"+i+"'";
             if (i==1)
                new_html+=" selected";
             new_html+=">"+(i)+"</option>";
         }
         //jQuery("#wbible_chapter").html(new_html);
    });*/

    //jQuery("#wbible_search").click(function(){
       
    //});
    
    // triger change event of wbible_book
    /*jQuery("#wbible_book").trigger("change");*/
});